package com.wp.redis;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

public class RedisTest {
    public static void main(String[] args) throws IOException {
        //连接redis服务器(在这里是连接本地的)
        Set<HostAndPort> nodes = new HashSet();
        nodes.add(new HostAndPort("192.168.100.150", 7001));
        nodes.add(new HostAndPort("192.168.100.150", 7002));
        nodes.add(new HostAndPort("192.168.100.151", 7003));
        nodes.add(new HostAndPort("192.168.100.151", 7004));
        nodes.add(new HostAndPort("192.168.100.152", 7005));
        nodes.add(new HostAndPort("192.168.100.152", 7006));
        JedisCluster cluster = new JedisCluster(nodes);

//        cluster.set("test", "test");
//        String val = cluster.get("test");
//        System.out.println(val);
        System.out.println(cluster.exists("test"));
        cluster.close();
    }
}